using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PACKETPARSERMAX20.CORE
{
	public class skill_discovery_template : MangosBase
	{
		public System.UInt32? spellid;
		public System.UInt32? reqspell;
		public System.UInt16? reqskillvalue;
		public System.Single? chance;




		public override string GetInsertCommand()
		{
			return string.Format("INSERT IGNORE INTO `skill_discovery_template` (`spellid`, `reqspell`, `reqskillvalue`, `chance`) VALUES ('{0}', '{1}', '{2}', '{3}');", spellid.GetValueOrDefault(), reqspell.GetValueOrDefault(), reqskillvalue.GetValueOrDefault(), chance.GetValueOrDefault());
		}


		public override string GetUpdateCommand()
		{
            StringBuilder sb = new StringBuilder();
						sb.Append("UPDATE `skill_discovery_template` SET ");
			if(reqspell != null)
			{
				sb.AppendLine("`reqspell`='" + reqspell.Value.ToString() + "'");
			}
			if(reqskillvalue != null)
			{
				sb.AppendLine("`reqskillvalue`='" + reqskillvalue.Value.ToString() + "'");
			}
			if(chance != null)
			{
				sb.AppendLine("`chance`='" + chance.Value.ToString() + "'");
			}
				sb = sb.Replace("\r\n", ", ");
				sb.Append(" WHERE `spellid`='" + spellid.Value.ToString() + "';");
				sb = sb.Replace(",  WHERE", " WHERE");

            return sb.ToString();
		}


	}
}
